/**
 * 查询厂商
 * @param vendorId
 */
function searchVendor(status){
	var selectList = document.getElementById("select");
	var index = selectList.selectedIndex;
	var vendorId = selectList.options[index].value;
	window.location.href = "searchVendor?vendorId="+vendorId +"&pageStr=0";
}

/**
 * 分页查询
 */
function pageSearch(pageStr){
	var vendorId = $("#vendorId").val();
	var pageIndex = $("#pageIndex").val();
	var currentPage = $("#currentPage").val();
	var totalCount = $("#totalCount").val();
	//当点击上一页时
	if(pageStr == 2){
		if(pageIndex == 0){
			alert("已经是第一页了！");
			return;
		}
	}
	//当点击下一页时
	if(pageStr == 1){
		currentPage = parseInt(currentPage) +1;
		if(currentPage > totalCount){
			alert("已经是最后一页了！");
			return;
		}
	}
	window.location.href = "searchVendor?vendorId="+vendorId +"&pageStr="+pageStr;
}


/**
 * 修改厂商
 * @param vendorId
 */
function editVendor(vendorId){
	window.location.href = "editVendor?vendorId="+vendorId;
}

/**
 * 新增厂商
 */
function insertVendor(){
	window.location.href = "insertVendor";
}

/**
 * 保存厂商
 */
/*function saveVendor(){
	var vendorName = $("#vendorName").val();
	var vendorId = $("#vendorId").val();
	if(vendorId == null){
		vendorId = 0;
	}
	var vendorCode = $("#vendorCode").val();
	var address = $("#address").val();
	var phone = $("#phone").val();
	var vendorUrl = $("#vendorUrl").val();
	var postcode = $("#postcode").val();
	
	//保存验证
	if(isEmpty(vendorName)){
		alert("请输入公司名称");
		return;
	}else if(isEmpty(vendorCode)){
		alert("请输入工商字号");
		return;
	}else if(!checkEnNum(vendorCode)){
		alert("工商字号只能为数字或者字符");
		return;
	}else if(isEmpty(address)){
		alert("请输入通讯地址");
		return;
	}else if(isEmpty(phone)){
		alert("请输入联系电话");
		return;
	}else if(!checkMobilePhone(phone) && !checkTelephone(phone)){
		alert("请输入正确的联系电话");
		return;
	}else if(isEmpty(vendorUrl)){
		alert("请输入公司网址");
		return;
	}else if(!isURL(vendorUrl)){
		alert("请输入正确的网址");
		return;
	}else if(isEmpty(postcode)){
		alert("请输入邮政编号");
		return;
	}else{
		$.ajax({
            type: "POST",
            url: "checkVendorName",  //换成你要请求的action, paperId 是url参数
            data: {vendorId:vendorId, vendorName:vendorName},
            async: false,
            dateType:'text',
            success: function(data){
            	if(data== 'success'){
            		document.myform.submit();
            	}else{
            		alert("系统中有重复的公司名称，请重新输入");
            	}
            }
       });
		
	}
}*/

/**
 * 删除
 */
function delVendor(vendorId){
	if(confirm("您确定要删除该条数据吗？")){
		$.ajax({
            type: "POST",
            url: "deleteVendor",  //换成你要请求的action, paperId 是url参数
            data: {vendorId:vendorId},
            async: false,
            dateType:'text',
            success: function(msg){
            	alert("删除成功！")
				location.reload();
            }
       });
	}
}


